Add alignment candidate options and enhance OSWReader for selection#210
Merged
singjc merged 3 commits intoPyProphet:masterfrom May 8, 2026
Merged
Add alignment candidate options and enhance OSWReader for selection#210singjc merged 3 commits intoPyProphet:masterfrom
singjc merged 3 commits intoPyProphet:masterfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds optional use of FEATURE_MS2_ALIGNMENT_CANDIDATE for across-run alignment group mapping in the IPF workflow, exposing configuration/CLI knobs to control candidate usage and minimum mapping confidence.
Changes:
- Added
use_alignment_candidatesandmin_alignment_mapping_confidencetoIPFIOConfigand wired them through thepyprophet ipfCLI. - Updated OSW (DuckDB + SQLite) alignment mapping readers to optionally read from
FEATURE_MS2_ALIGNMENT_CANDIDATE, filter byMAPPING_CONFIDENCE, and fall back when the table is absent. - Updated related config documentation.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
pyprophet/io/ipf/osw.py |
Adds candidate-table-based alignment mapping queries for DuckDB and SQLite, with fallback behavior. |
pyprophet/cli/ipf.py |
Introduces CLI flags/options to enable candidate mapping and set the minimum mapping confidence. |
pyprophet/_config.py |
Extends IPFIOConfig with the new alignment candidate options and wires them through from_cli_args. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+307
to
+357
| logger.info( | ||
| "Using FEATURE_MS2_ALIGNMENT_CANDIDATE for across-run alignment groups " | ||
| f"with MAPPING_CONFIDENCE >= {min_confidence}." | ||
| ) | ||
| query = f""" | ||
| SELECT | ||
| DENSE_RANK() OVER (ORDER BY merged.PRECURSOR_ID, merged.ALIGNMENT_ID) AS ALIGNMENT_GROUP_ID, | ||
| merged.ALIGNMENT_ID, | ||
| merged.FEATURE_ID, | ||
| merged.PRECURSOR_ID, | ||
| merged.FEATURE_TYPE | ||
| FROM ( | ||
| SELECT DISTINCT | ||
| fmac.ALIGNMENT_ID, | ||
| fmac.REFERENCE_FEATURE_ID AS FEATURE_ID, | ||
| fmac.PRECURSOR_ID, | ||
| 'REFERENCE' AS FEATURE_TYPE | ||
| FROM osw.FEATURE_MS2_ALIGNMENT_CANDIDATE AS fmac | ||
| WHERE fmac.SELECTED = 1 | ||
| AND fmac.MAPPING_CONFIDENCE >= {min_confidence} | ||
| AND fmac.REFERENCE_FEATURE_ID != fmac.ALIGNED_FEATURE_ID | ||
| AND fmac.ALIGNED_FEATURE_ID != -1 | ||
|
|
||
| UNION | ||
|
|
||
| SELECT DISTINCT | ||
| fmac.ALIGNMENT_ID, | ||
| fmac.ALIGNED_FEATURE_ID AS FEATURE_ID, | ||
| fmac.PRECURSOR_ID, | ||
| 'QUERY' AS FEATURE_TYPE | ||
| FROM osw.FEATURE_MS2_ALIGNMENT_CANDIDATE AS fmac | ||
| WHERE fmac.SELECTED = 1 | ||
| AND fmac.MAPPING_CONFIDENCE >= {min_confidence} | ||
| AND fmac.REFERENCE_FEATURE_ID != fmac.ALIGNED_FEATURE_ID | ||
| AND fmac.ALIGNED_FEATURE_ID != -1 | ||
| ) AS merged | ||
| ORDER BY | ||
| ALIGNMENT_GROUP_ID, | ||
| CASE merged.FEATURE_TYPE | ||
| WHEN 'REFERENCE' THEN 0 | ||
| WHEN 'QUERY' THEN 1 | ||
| END; | ||
| """ | ||
|
|
||
| df = con.execute(query).fetchdf() | ||
| return df.rename(columns=str.lower) | ||
|
|
||
| logger.warning( | ||
| "Requested FEATURE_MS2_ALIGNMENT_CANDIDATE for IPF propagation, " | ||
| "but the table was not found. Falling back to FEATURE_MS2_ALIGNMENT." | ||
| ) |
Comment on lines
+596
to
+620
| if use_alignment_candidates: | ||
| if check_sqlite_table(con, "FEATURE_MS2_ALIGNMENT_CANDIDATE"): | ||
| logger.info( | ||
| "Using FEATURE_MS2_ALIGNMENT_CANDIDATE for across-run alignment groups " | ||
| f"with MAPPING_CONFIDENCE >= {min_confidence}." | ||
| ) | ||
| query = """ | ||
| SELECT | ||
| DENSE_RANK() OVER (ORDER BY PRECURSOR_ID, ALIGNMENT_ID) AS ALIGNMENT_GROUP_ID, | ||
| ALIGNMENT_ID, | ||
| FEATURE_ID, | ||
| PRECURSOR_ID, | ||
| FEATURE_TYPE | ||
| FROM ( | ||
| SELECT DISTINCT | ||
| ALIGNMENT_ID, | ||
| PRECURSOR_ID, | ||
| REFERENCE_FEATURE_ID AS FEATURE_ID, | ||
| 'REFERENCE' AS FEATURE_TYPE | ||
| FROM FEATURE_MS2_ALIGNMENT_CANDIDATE | ||
| WHERE SELECTED = 1 | ||
| AND MAPPING_CONFIDENCE >= ? | ||
| AND REFERENCE_FEATURE_ID != ALIGNED_FEATURE_ID | ||
| AND ALIGNED_FEATURE_ID != -1 | ||
|
|
Comment on lines
+305
to
+307
| if use_alignment_candidates: | ||
| if check_duckdb_table(con, "main", "FEATURE_MS2_ALIGNMENT_CANDIDATE"): | ||
| logger.info( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request adds support for using candidate alignments from the
FEATURE_MS2_ALIGNMENT_CANDIDATEtable for across-run alignment in IPF propagation, with configurable options for minimum mapping confidence and fallback behavior. It introduces new CLI options, updates configuration handling, and implements the logic for both DuckDB and SQLite backends.New alignment candidate support:
IPFIOConfigand the CLI:use_alignment_candidates(to enable usingFEATURE_MS2_ALIGNMENT_CANDIDATEtable) andmin_alignment_mapping_confidence(to set the minimumMAPPING_CONFIDENCErequired for candidate alignments). [1] [2] [3]Backend implementation:
FEATURE_MS2_ALIGNMENT_CANDIDATEwhen enabled, filtering byMAPPING_CONFIDENCE, and falling back toFEATURE_MS2_ALIGNMENTif the candidate table is not available. [1] [2]